import pandas as pd
import os

def readCsv_sd_AD(filepath, begin_frame, interval_frame):
    ret_data_arr = []
    for i in range(4):
        data = pd.read_csv(f"{filepath}{begin_frame+interval_frame*i}.csv", header=None)
        # data = pd.read_csv(f"{filePath}{begin_frame + i}.csv", header=None)
        ret_data_arr.append(data.values)
    return ret_data_arr

def readCsv_ccc_AD(filepath, begin_frame, end_frame):
    ret_data_arr = []
    t = 0
    for i in range(begin_frame, end_frame):
        data = pd.read_csv(f"{filepath}{i}.csv", header=None)
        # data = pd.read_csv(f"{filePath}{begin_frame + i}.csv", header=None)
        ret_data_arr.append(data.values)
        t = t + 1
    print(f'{t}张图片的AD值已读取完成')
    return ret_data_arr

def readCsv_AD(filepath):
    ret_data_arr = []
    files = os.listdir(filepath)
    num_csv = len(files)
    print(f'文件夹内共有{num_csv}个csv文件。')
    t = 0
    for i in range(num_csv):
        t = i + 1
        data = pd.read_csv(f"{filepath}{t}.csv", header=None)
        ret_data_arr.append(data.values)

    print(f'{t}张图片的AD值已读取完成')
    return ret_data_arr, num_csv
